package ${packageName};

<#list importList! as each>
import ${each};
</#list>

import org.springframework.stereotype.Repository;

@Repository
public class ${prefix!}${domain}${surffix!}<#if extendsStr??> extends ${extendsStr!}</#if> <#list implementsList as each><#if each_index == 0> implements</#if> ${each}<#if each_has_next>, </#if></#list>{
	public static final String NAMESPACE = "${domain}";

	public int insert(${domain} ${domainVariable}) {
		Integer id = (Integer)getSqlMapClientTemplate().insert(getStatementName(NAMESPACE, "insert"), ${domainVariable});
		return id;
	}

	public int update(${domain} ${domainVariable}) {
		return getSqlMapClientTemplate().update(getStatementName(NAMESPACE, "update"), ${domainVariable});
	}
	
	public int delete(<#list primaryKeyMappers as primaryKeyMapper>${primaryKeyMapper.fieldType} ${primaryKeyMapper.fieldName}<#if primaryKeyMapper_has_next>, </#if></#list>) {
		Map<String, Object> params = new HashMap<String, Object>();
		<#if primaryKeyMappers?size &gt; 0><#list primaryKeyMappers as primaryKeyMapper>params.put("${primaryKeyMapper.fieldName}", ${primaryKeyMapper.fieldName});</#list></#if>
		return getSqlMapClientTemplate().delete(getStatementName(NAMESPACE, "delete"), params);	
	}
	
	public ${domain} select(<#list primaryKeyMappers as primaryKeyMapper>${primaryKeyMapper.fieldType} ${primaryKeyMapper.fieldName}<#if primaryKeyMapper_has_next>, </#if></#list>) {
		Map<String, Object> params = new HashMap<String, Object>();
		<#if primaryKeyMappers?size &gt; 0><#list primaryKeyMappers as primaryKeyMapper>params.put("${primaryKeyMapper.fieldName}", ${primaryKeyMapper.fieldName});</#list></#if>
		return (${domain})getSqlMapClientTemplate().queryForObject(getStatementName(NAMESPACE, "select"), params);
	}

	@SuppressWarnings("unchecked")
	public List<${domain}> search(${domain}Search search) {
		return getSqlMapClientTemplate().queryForList(getStatementName(NAMESPACE, "search"), search);
	}
}